package czk;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Teacher {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>(10);
        list.add("1");
        list.add("2");
        /**
         * 报错
         *  for (String s : list) {
         *             if (s.equals("2")){
         *                 list.remove(s);
         *             }
         *         }
         */
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            if (next.equals("2")){
                iterator.remove();
            }
        }
        System.out.println(list);
    }
}
